public class Enemy {
    String type;
    String name;
    int life;
    int attack;
    int defense;
    int agile;
    boolean isLive;
    int giveExp;

    Enemy(String type,String name) {
        this.type = type;
        this.name = name+"["+type+"]";
        this.isLive = true;
        if(this.type=="僵尸") {
            this.life = 31;
            this.attack = 18;
            this.defense = 10;
            this.agile = 6;
            this.giveExp = 20;
        } else if(this.type=="吸血鬼") {
            this.life = 49;
            this.attack = 20;
            this.defense = 5;
            this.agile = 8;
            this.giveExp = 25;
        } else if(this.type=="野兽") {
            this.life = 30;
            this.attack = 23;
            this.defense = 8;
            this.agile = 10;
            this.giveExp = 25;
        } else if(this.type=="boss") {
            this.life = 100;
            this.attack = 35;
            this.defense = 10;
            this.agile = 4;
            this.giveExp=80;
        }
    }

    public void show() {
        System.out.println("-----------------------------------------------------------------");
        System.out.println("怪物名称:\t"+this.name+"\t生命:"+this.life);
        System.out.println("基础属性:\t攻击力:"+this.attack+"\t防御力:"+this.defense+"\t敏捷:"+this.agile);
        System.out.println("------------------------------------------------------------------");
    }

    public void injured(int lostLife,Player player) {
        //0、判断闪避
        if(Tools.checkRate(this.agile)) {
            Tools.randomSay(this.name+"哇哈哈哈！打不到我");
        } else {
            //1、口号
            Tools.enemySay(this.name+":哇哇哇!居然敢打我!["+lostLife+"]");
            //2、损失生命
            this.life-=lostLife;
            //3、反击
            //3.1、判断是否死亡
        }
        if(this.life<=0) {
            Tools.enemySay(this.name+":呃呃呃!下线啦!");
            this.isLive = false;
            return;
        }
        //3.2、没有死亡，就要反击
        Tools.enemySay(this.name+":小样，敢打我，接招!");
        int playerLostLife = this.attack - player.defense;
        if(playerLostLife<=0) {
            playerLostLife = 1;
        }
        player.injured(playerLostLife);
    }
}
